Replication code for "When Does Income Inequality Cause Polarization?" British Journal of Political Science
Author: Jacob R. Gunderson, University of North Carolina at Chapel Hill, jacob.gunderson@unc.edu

Operating system:

- HP Laptop 15-bs0xx
- Intel(R) Core(TM) i7-7500U CPU @ 2.70 GHz 2.90 GHz
- Installed RAM 8.00 GB
- Windows 10 Home

Analyses completed using R 3.6.1 (2019-07-05) and Stata 14.2 SE

Packages: 

  plm_2.2-0          plyr_1.8.6        
  MASS_7.3-51.4      lme4_1.1-21       
  Matrix_1.2-17      schoolmath_0.4    
  imputeTS_3.0       manifestoR_1.4.0  
  tibble_2.1.3       tm_0.7-6          
 NLP_0.2-0          rio_0.5.16        
 SDMTools_1.1-221.1 dplyr_1.0.2       
 readxl_1.3.1       readr_1.3.1 

Estimated run time for all analyses: < 1 hour 

List of files:

	Data Files:
		pols_bjps (Saved using the saveRDS)

	Code:
		00. Master_file.R
			Sets up the environment and runs all other scripts

			Scripts 01-04 create pols_bjps. See Codebook.pdf for information about the extrenal data sources used.

		01.Ches_prep.R
			Merges the CHES data sets and calculates polarization
		02.Salience_and_controls.R
			Calculates the salience of economic issues and merges other controls
		03. Horizontal_inequality.R
			Calculates the horizontal inequality indexes
		04. final_data_adjustments_and_saving.R
			Makes final adjustments to the data and saves pols_bjps for later analyses
		
		05.Figure_1_2.R
			Creates Figures 1 and 2
		06.Table1.r
			Outputs the values presented on Table 1 as well as Table A11
		07.Figures_3_4.R
			Creates Figures 3 and 4 to visualize model output in Table 1
		08.Table_2.R
			Produces the values for Table 2
		09.Figure_5.R
			Produces Figure 5
		10.sum_stat.R
			Produces the values for Table A3, A4, A5, and A7
		11.Figure_A1.R
			Produces Figure A1
		12.CSES_only.R
			Produces Table A8
		13.Table_10_fe_alternate_inc_dif.R
			Produces Table A9
		14.robustness_drop.R
			Produces Figure A2
		15.MLM_marginaleffects.R
			Produces Figure A2
		16.Robustness Check with WIID.R
			Produces Table A12 and Figures A5 and A6
		17.West_europe_data.R
			Produces Table A13 and Figures A7 and A8
		18.Robustness_alt_econ.R
			Produces the values for Table A14
		19.fe_single_int.R
			Produces Figure A9
		20.mlm_single_int.R
			Produces Figure A10
